package com.jhl.seckill.controller;

import com.jhl.seckill.service.UserService;
import com.jhl.seckill.vo.LoginVo;
import com.jhl.seckill.vo.RespBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
@RequestMapping("/login")
@Slf4j
public class LoginController {


    @Autowired
    UserService UserService;


    @GetMapping("/toLogin")
    public String toLogin() {

        return "login";
    }

    @RequestMapping(value = "/doLogin", method = RequestMethod.POST)
    @ResponseBody
    public RespBean doLogin(@RequestBody LoginVo loginVo, HttpServletRequest request, HttpServletResponse response) {
        log.info("{}", loginVo);

        return UserService.doLogin(loginVo, request, response);
    }
}
